<%
    System.out.println("======== CFHDCMT06============");
//--------------------------------------------------------------------------------->
//
// Copyright 2002 e Professional Corporation.  All Rights Reserved.
//
// File:       	CFHDPCMT06.jsp
//
// Author:   	Noom
//
// Start Date:	20/12/47
//
// Finish Date: XX/XX/XXXX
//
// Update Date : 30/12/2004 by Udong
// ...........get name and surname who is owner case (user in sequence0).............
//
// Update Date : xx/xx/xxxx by Who
// ............????????..........

//--------------------------------------------------------------------------------->
 //errorPage		="../include/eproErrorPage.jsp"
%>

<%//@include file="../include/eproAuthorization.jsp"%>
<%@ page

	contentType	="text/html; charset=TIS-620"
        import		="com.epro.standard.usermenu.UserAccountVO,
                        com.epro.standard.frontend.util.FileInfoUtil,
                        com.epro.standard.frontend.util.EproServletUtil,
                        com.epro.standard.frontend.util.ShowData,
                        java.util.Vector,
                        java.text.DecimalFormat,
		 java.text.SimpleDateFormat,
         java.util.Calendar,
         java.util.GregorianCalendar,

         com.softplus.carrefour.hd.CFHDSystem,
         com.softplus.carrefour.hd.bltier.pc.CCaseHeadManage ,
         com.softplus.carrefour.hd.bltier.pc.ICaseHeadViewer,
         com.softplus.carrefour.hd.bltier.entity.CfhdCaseHead ,
         com.softplus.carrefour.hd.bltier.admin.CFHDSystemManage,

         com.softplus.carrefour.hd.bltier.pc.CCaseDetailManage,
         com.softplus.carrefour.hd.bltier.pc.ICaseDetailViewer,
         com.softplus.carrefour.hd.bltier.entity.CfhdCaseDetail,

        com.softplus.carrefour.hd.bltier.pc.CCaseDocManage,
         com.softplus.carrefour.hd.bltier.pc.ICaseDocViewer,
        com.softplus.carrefour.hd.bltier.entity.CfhdCaseDoc,

        com.softplus.carrefour.hd.bltier.entity.CfhdCaseDocPK,
        java.math.BigDecimal,

        com.softplus.carrefour.hd.bltier.entity.CfhdCaseDetailPK,
         com.softplus.carrefour.hd.bltier.entity.UserAccount,
         com.softplus.carrefour.hd.bltier.admin.IUserLevelViewer,
         com.softplus.carrefour.hd.bltier.admin.UserLevelManage,
         com.softplus.carrefour.CFException,
         com.softplus.carrefour.hd.bltier.entity.UserLevel"

%>
<HTML xmlns:epro>
<%@ taglib uri="/WEB-INF/HeadTag.tld" prefix="head"%>
<%@ taglib uri="/WEB-INF/ToolbarTag.tld" prefix="toolbar"%>
<%@ taglib uri="/WEB-INF/TextfieldTag.tld" prefix="textfield"%>
<%@ taglib uri="/WEB-INF/TextareaTag.tld" prefix="textarea"%>
<%@ taglib uri="/WEB-INF/ListboxTag.tld" prefix="listbox"%>
<%@ taglib uri="/WEB-INF/ErrorTag.tld" prefix="error"%>
<head:Head
	author		="Noom"
	title				="Case Detail:Update Case"
	import		="toolbar,textfield,textarea,listbox"
	jsFile			="../script/spTitleRefresh.js,../script/imgProp.js,../script/Alert.js,../script/checkValidData.js,../script/convertDataType.js,../script/dateCalendar.js,../script/historytable.js"
	styleFile	="../theme/defaultTheme.css,../theme/historyTableTheme.css"></head:Head>
	<%//@include file="../include/eproFileInfo.jsp" %>
<%
//	FileInfoUtil fileInfoUtil	= (FileInfoUtil)session.getAttribute("fileInfoUtil");
	FileInfoUtil	fileInfoUtil 	= session.getAttribute("fileInfoUtil")!=null?(FileInfoUtil)session.getAttribute("fileInfoUtil"):new FileInfoUtil() ;

        fileInfoUtil.setMenuIDCode("CFHDPCMT06 ");
		fileInfoUtil.setMenuName(" View by Case") ;
        fileInfoUtil.setMasterWording(" View by Case ");
		fileInfoUtil.setMenuDesc(" View by Case") ;

	ShowData showData 	= new ShowData();
//	String masterWidth 			= com.epro.standard.frontend.datasetup.MessageManager.getMasterDetailWidth();
	String linkParameter 		= "?";

   		String tableWidth			= "735";
		String tableWidth1		= "745";
		String labelColWidth	= "150";
        String labelColWidth2	= "150";

		String inputColWidth	= "200";
		String inputColWidth1	= "10%";

		String longBoxWidth	= "523";
		String buttonWidth		= "70";
 		String longBoxWidthAttachment	= "445";

 //-=========================================
          String          viewAllCaseURL  = "/CFHD/servlet/com.softplus.carrefour.hd.frontend.servlet.process.CFHDPC01";

          String          backURL = viewAllCaseURL;

          if(session.getAttribute("fileInfoUtil")!=null){
               backURL   = java.net.URLDecoder.decode(((FileInfoUtil) session.getAttribute("fileInfoUtil")).getBackToMenu());
               System.out.println("== can get back from session ==");
          }



// System.out.println("@@@@@@@@@@viewAllCaseURL="+viewAllCaseURL);
           String backClick						= "window.location='" + backURL + "'" ;

             backClick = request.getParameter("search")!=null?"Javascript:history.back(); ":backClick; //come from search page.
//               backClick = "Javascript:history.back(); ";


          System.out.println("====== >"+backURL+"<");
// -=========================================

  UserAccount     userVO          =    (UserAccount)session.getAttribute("userVO");
 System.out.println(" ==vo== "+ session.getAttribute("userVO"));

 String userid=userVO.getUserId();
 System.out.println(" =userid===!!!!!!!!!!!!!!!!!!!!!!!!!! "+ userid);


 //===========================================

   // int vectorSize    =  10; //data vector size.
    Calendar                    gCal                = new GregorianCalendar();
    SimpleDateFormat  sdFormat       = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    //-----------------------------------------------
//	String caseID = request.getParameter("caseno") == null ? "66/211104/00005/admin" : request.getParameter("caseno");
	String caseID = request.getParameter("caseno") == null ? "nocase" : request.getParameter("caseno");
     System.out.println(" =caseID===!!!!!!!!!!!!!!!!!!!!!!!!!! "+ caseID);

     //   IF there's no case id it should not continue...
     if(!caseID.equalsIgnoreCase("nocase")){
    // create manager
    //-----------Part Contact Information  Case Information------------------------------------------
      ICaseHeadViewer  caseheadManage  =   (CCaseHeadManage) CFHDSystem.getControlClass("CASE_HEAD");
      CfhdCaseHead           caseheadEntity   =   caseheadManage.getCaseHeadDesc(caseID);
    //     String OpenCaseDate = showData.CheckNull(caseheadEntity.getOpenCaseDate(),"");
  //    String ClosedCaseDate = showData.CheckNull(caseheadEntity.getCloseCaseDate(),"");


    //-----------Detail-----------------------------------------
      ICaseDetailViewer  casedetailManage  = ( CCaseDetailManage)CFHDSystem.getControlClass("CASE_DETAIL");
     CfhdCaseDetail           casedetailEntity  =   casedetailManage.getCaseHeadDetail(caseID);

         System.out.println("======RRRR==============casedetailEntity="+casedetailEntity);


      //-----------Attachment  Description----------------------------------------
     ICaseDocViewer  casedocManage  = (com.softplus.carrefour.hd.bltier.pc.CCaseDocManage)CFHDSystem.getControlClass("CASE_DOC");
     CfhdCaseDoc           casedocEntity  =   casedocManage.getCaseDocByPK(new CfhdCaseDocPK(caseID,new BigDecimal(0),new BigDecimal(0) ));
    System.out.println("====================casedocEntity="+casedocEntity);

//------getCaseDetailbyCaseHead----------------
 //      Vector           vectorCaseDetailbyCaseHead  =   casedetailManage.getCaseDetailbyCaseHead(caseID);
    // modified by ong
    Vector           vectorCaseDetailbyCaseHead  =   casedetailManage.getHistoryCaseDetail(caseID,userid);
                                                          int  vectorSize =   vectorCaseDetailbyCaseHead.size();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Udong : change reporter name to be owner case of sequence 0
		UserLevelManage	levelManage	=	(UserLevelManage) CFHDSystem.getControlClass("USER_LEVEL");
		CfhdCaseDetail    	dataDetail 		=	(CfhdCaseDetail) vectorCaseDetailbyCaseHead.elementAt(0);
//		UserLevel					levelEntity		=	(UserLevel) levelManage.getUserLevel(dataDetail.getUserId());
//		String		nameSeq0			=	levelEntity.getUserAccount().getUserName()==null? "":levelEntity.getUserAccount().getUserName();
//		String		surnameSeq0	=	levelEntity.getUserAccount().getUserSurname()==null? "":levelEntity.getUserAccount().getUserSurname();
		UserAccount		levelEntity		     =	(UserAccount) levelManage.getUserAccount(dataDetail.getUserId());
 		String		          nameSeq0		=	levelEntity.getUserName()==null? "":levelEntity.getUserName();
 		String		          surnameSeq0	=	levelEntity.getUserSurname()==null? "":levelEntity.getUserSurname();

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    	String attFileNameNew ="";
    	//System.out.println("=====^^^^^^^^1111^^^^^^^^attFileNameNew^^^^^^^^^^^^^^^"+attFileNameNew);
try{
     if((casedocEntity!=null) &&(casedocEntity.getAttFileName()!=null))
     {
			attFileNameNew = java.net.URLDecoder.decode(casedocEntity.getAttFileName());
			System.out.println("=====^^^^^^^^^^^^^^^^attFileNameNew^^^^^^^^^^^^^^^"+attFileNameNew);
	}
}catch(java.lang.IllegalArgumentException e)
{attFileNameNew=casedocEntity.getAttFileName() ;
System.out.println("=====^^^^^^^^^error error error^^^^^^^^^"+attFileNameNew);     }

%>
<%//@include file="../include/eproPopupJsp.jsp"%>
  <%@ include file="../include/eproErrorAlert.jsp"%>
  <BODY>
<%=fileInfoUtil.MasterHeadTable()%>
<DIV style="width:100%;height:90%;margin:5px"><!-- class="modalBg" -->
     <%//@include file="../include/softplusModalDialogToolbar.jsp"%>
	<CENTER>
		<FORM name="frm" action="../servlet/com.softplus.carrefour.hd.frontend.servlet.process.CFHDPC06" method="get" >
<input type="hidden" name="caseId"  value="">
<input type="hidden" name="detSeq"  value="">
<input type="hidden" name="docSeq"  value="">
<input type="hidden" name="action"  value="">

<!-------------Case No.------Case Status-- Close Case-----Back---------------------------------->
<TABLE width="<%=tableWidth1%>"  border="0">
	<TR>
		<TD class="titleFont" colspan="2" align="left">Case No. : </TD>
		<TD  width="<%=inputColWidth1%>" align="right"><span class="disabledTxtField" style="white-space:nowrap;"><%=caseID%></span><!-- <INPUT type="text" readonly="readonly" class="disabledTxtField" value="<%-- =caseID --%>"> --></TD>
	</TR>
	<TR>
		<TD><!--INPUT type="button" value="Close Case" style="width: <%=buttonWidth%>"-->
		        <!--INPUT type="button" value="Back" style="width: <%=buttonWidth%>"-->
               	<IMG alt="Back" src="../images/icon/toolbar/nBackToMenu.gif" onmouseover="this.src='../images/icon/toolbar/oBackToMenu.gif'" onmouseout="this.src='../images/icon/toolbar/nBackToMenu.gif'" style="cursor:hand" onclick="<%=backClick%>">

<%
    IUserLevelViewer       ulViwer  = (UserLevelManage)CFHDSystem.getControlClass("USER_LEVEL");
    String  uLevel                 = "";

    try{
        uLevel   = ulViwer.getUserLevelByUserID(userid)==null? "":ulViwer.getUserLevelByUserID(userid);// udong updated cause admin have not user level
    }catch(NullPointerException ne){
        //throw new CFException("4002");	// udong updated cause admin have not user level
        //ne.printStackTrace();	// udong updated cause admin have not user level
    }
     System.out.println(" =====  !!!!!userid > "+userid);
     System.out.println(" === !!!!!!!!!U Level > "+uLevel);
	
     String rptBy = caseheadEntity.getReportedBy()==null? "":caseheadEntity.getReportedBy();
// if(    (uLevel.equals("L1C"))   &&    ( caseheadEntity.getCaseStatus().equals("FIN") ||  caseheadEntity.getCaseStatus().equals("CCD") )     ){
 if( (uLevel.equals(UserLevel.LEVEL_1_COUNTRY_HELPDESK))&&(rptBy.equals(""))
     && (caseheadEntity.getCaseStatus().equals(caseheadEntity.STATUS_FINISH)
     ||  caseheadEntity.getCaseStatus().equals(caseheadEntity.STATUS_CANCEL)) ){
%>
  <IMG alt="Close Case" src="../images/icon/toolbar/nCloseCase.gif" onmouseover="this.src='../images/icon/toolbar/oCloseCase.gif'" onmouseout="this.src='../images/icon/toolbar/nCloseCase.gif'" style="cursor:hand" onclick="CloseCase()">
<%
}else if( (uLevel.equals(UserLevel.LEVEL_2_AMS_ZONE_ASIA))&&(!rptBy.equals(""))
	&& (caseheadEntity.getCaseStatus().equals(caseheadEntity.STATUS_FINISH)
	||  caseheadEntity.getCaseStatus().equals(caseheadEntity.STATUS_CANCEL)) ){
%>
	<IMG alt="Close Case" src="../images/icon/toolbar/nCloseCase.gif" onmouseover="this.src='../images/icon/toolbar/oCloseCase.gif'" onmouseout="this.src='../images/icon/toolbar/nCloseCase.gif'" style="cursor:hand" onclick="CloseCase()">
<%
}
%>
    </TD>
    <TD class="titleFont"  align="right">Case Status : </TD>
    <TD width="<%=inputColWidth1%>" align="right"><INPUT type="text" readonly="readonly" class="disabledTxtField" value="<%= CfhdCaseHead.getStatusDesc(caseheadEntity.getCaseStatus())%>"> </TD>
</TR>
<%
//--------------------------------------Unlock---------------------
  System.out.println(" ZZZZZZZZZZ=userid > "+userid);
  CfhdCaseDetail          lastcasedetailEntityForUnlock  =     casedetailManage.getLastCaseDetailbyCaseHead(caseID);
  String  idLastUserDetailForUnlock = lastcasedetailEntityForUnlock.getUserId();
  System.out.println("ZZZZZZZZZZ=idLastUserDetailForUnlock > "+idLastUserDetailForUnlock);

    if ((userid.equals(idLastUserDetailForUnlock)) && (caseheadEntity.getCaseStatus().equals(caseheadEntity.STATUS_VALIDATED))) {
%>
<TR>
  <TD colspan="3">
    <IMG alt="Unlock" src="../images/icon/toolbar/nUnlock.gif" onmouseover="this.src='../images/icon/toolbar/oUnlock.gif'" onmouseout="this.src='../images/icon/toolbar/nUnlock.gif'" style="cursor:hand" onclick="UnlockCase()">
    <FONT class="titleFont2" color="red" >Note: the case is currently locked. Before unlock this case, please make sure that no one is updating it at this moment.</FONT>
  </TD>
</TR>
<%
}
%>
</TABLE>
<!-- -->

<TABLE align="center" width="100%">
<!-- 11111111111111-Contact Information -->
<TR>
<TD colspan="3">
<FIELDSET style="width:<%=tableWidth%> ">
<LEGEND class="titleFont">Contact Information</LEGEND>
<TABLE width="<%=tableWidth%>">
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Requester Name : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" name="reqName"   value="<%=showData.CheckNull(caseheadEntity.getReqName())%>" readonly="readonly" class="disabledTxtField" style="width: <%=longBoxWidth%>" ></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Tel No. : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" name="telephone" value="<%=showData.CheckNull(caseheadEntity.getReqTel())%>"  readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>">Fax No. : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" name="fax"  value="<%=showData.CheckNull(caseheadEntity.getReqFax())%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>

</TABLE>
</FIELDSET>
					</TD>
				</TR>

				<!----------------------------------------------------------------------222222222----Case Information------------------------------------------------------------------------------------>
				<TR>
					<TD colspan="3">
						<FIELDSET class="titleFont">
						<LEGEND class="titleFont">Case Information</LEGEND>

						<TABLE align="center" width="100%" border="0">
						   <!--INPUT type="hidden" name="roleID"-->
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Open Case Date : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" name="OpenCaseDate" value="<%=showData.CheckNull(caseheadEntity.getOpenCaseDate(),"")%>"  readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>">Closed Case Date : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getCloseCaseDate(),"")%>"   readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Reporter Name : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text"   value="<%=nameSeq0%> <%=surnameSeq0%>"  style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Country : </TD>
		<TD width="<%=inputColWidth%>">

		<INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getCountry().getCountryName())%>" readonly="readonly" class="disabledTxtField" >
		</TD>
		<TD class="titleFont" width="<%=labelColWidth%>">Site : </TD>
		<TD width="<%=inputColWidth%>">
		<INPUT type="text"  value="<%=caseheadEntity.getStoreId()==null?"":showData.CheckNull(caseheadEntity.getMdStore().getStoreName())%>" readonly="readonly" class="disabledTxtField">
		</TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">System : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text"  value="<%=showData.CheckNull(caseheadEntity.getCfhdSystem())%>" readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>">Module : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text"  value="<%=showData.CheckNull(caseheadEntity.getCfhdModule())%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Aldata Internal No. : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getAlDataNo())%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">GOLD Version : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getGoldVersion())%>" readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>">Environment : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getCfhdEnvironment())%>"  readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Screen Name : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(caseheadEntity.getScreenName())%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
						</TABLE>

						</FIELDSET>
					</TD>
				</TR>

				<!--------------------------------------------------------------------------333333333333------Case Context----------------------------------------------------------------------------------->
				<TR>
					<TD colspan="3">
						<FIELDSET class="titleFont">
						<LEGEND class="titleFont">Case Context</LEGEND>

						<TABLE align="center" width="100%" border="0">
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Current Case Type : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getCaseTypeDesc(caseheadEntity.getCaseType()))%>" readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Current Severity : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getServerityDesc(caseheadEntity.getSeverity().toString()))%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Original Case Type : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getCaseTypeDesc(caseheadEntity.getOriginCaseType()))%>" readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Original Severity : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getServerityDesc(""+caseheadEntity.getOriginSeverity()))%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Subject : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text"   value="<%=showData.CheckNull(caseheadEntity.getSubject())%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
<%
if(casedetailEntity!=null){
%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Detail : </TD>
		<TD colspan="3"><TEXTAREA  rows="5"  cols="10" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"><%=showData.CheckNull(casedetailEntity.getDetDesc())%></TEXTAREA></TD>
	</TR>
<%
    }
 if(casedocEntity!=null){
%>
	<TR >
		<TD class="titleFont" width="<%=labelColWidth%>">Attachment : </TD>
		<TD colspan="3" >
     		<INPUT type="text"  value="<%=showData.CheckNull(attFileNameNew)%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField">
            <%if(!(showData.CheckNull(casedocEntity.getAttFileName()).equals(""))){       %>
	     <img src="../images/icon/toolbar/nSaveAs.gif" width="21" height="21" align="bottom" onClick="download(0)" alt="Download" >
	        <%}%>
		</TD>


	</TR>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Description : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><TEXTAREA cols="10" rows="5" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"><%=showData.CheckNull(casedocEntity.getAttDesc())%></TEXTAREA></TD>
	</TR>
<%
 }
%>

						</TABLE>

						</FIELDSET>
					</TD>
				</TR>

				<!----------------------------------------------------->


			</TABLE>
<%
//===========================================�������ǹ History========================================
          if(vectorSize>1){

%>

	<!-- Scroll Table -->
<span class="caseCategory">&nbsp;&nbsp;History&nbsp;</span>
<a href="Javascript:" class="caseCategory" onclick="expandAll('historyTable')" >expand all</a>
<a href="Javascript:" class="caseCategory" onclick="collapseAll('historyTable')" >collapse all</a>
<br>

<div id="tableContainer">
<table id="historyTable" width="99%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC" class="scrollTable">
<thead >
  <tr align="center">
    <th nowrap="nowrap" align="left" >Updated Date (from/to) </th>
    <th nowrap="nowrap" >Owner</th>
    <th nowrap="nowrap" >Country</th>
    <th nowrap="nowrap" >Status</th>
    <th nowrap="nowrap" >Action</th>
    <th nowrap="nowrap" >&nbsp;<!-- Action --></th>
  </tr>
  </thead>
    <tbody class="scrollContent">
  <%
          String historyBarClassname    = "trUnselect";
          String historyBarOnClickScript = "toggleContent(this)";
          String historyDescClassname = "trHidden";
///-------------=====================================-for-----==============================================-----------------------------
          for(int i=1; i<vectorSize;i++){
    %>
  <%
  /*
        if(i==(vectorSize-1)){ //If history is not complete HistoryDesc will not hiddin its content.
          historyBarOnClickScript = "modifyContent('keyInformation')";
          historyBarClassname    = "trUndefined";
          historyDescClassname = "trUndefined";
        }
     */
             CfhdCaseDetail    pdataCaseDetail =  (CfhdCaseDetail) vectorCaseDetailbyCaseHead.elementAt(i-1);
              //System.out.println("#############pdataCaseDetail="+pdataCaseDetail);
              //System.out.println("#############pdataCaseDetail getCaseDetType="+pdataCaseDetail.getCaseDetType());
              //System.out.println("#############pdataCaseDetail getCaseDetStatus="+pdataCaseDetail.getCaseDetStatus());
              //System.out.println("#############pdataCaseDetail getCaseDetServerity="+pdataCaseDetail.getCaseDetServerity());

             CfhdCaseDetail    cdataCaseDetail =  (CfhdCaseDetail) vectorCaseDetailbyCaseHead.elementAt(i);
             //System.out.println("#############cdataCaseDetail 0="+cdataCaseDetail);
             //System.out.println("#############cdataCaseDetail getCaseDetType="+cdataCaseDetail.getCaseDetType());
             //System.out.println("#############cdataCaseDetail getCaseDetStatus="+cdataCaseDetail.getCaseDetStatus());
             //System.out.println("#############cdataCaseDetail getCaseDetServerity="+cdataCaseDetail.getCaseDetServerity());
                 //------------------Attachment ��� Description  �ͧ History-----------

                       casedocEntity  =   casedocManage.getCaseDocByPK(new CfhdCaseDocPK(caseID,new BigDecimal(i),new BigDecimal(0) ));


			try{
			     if((casedocEntity!=null) &&(casedocEntity.getAttFileName()!=null))
			     {
						attFileNameNew = java.net.URLDecoder.decode(casedocEntity.getAttFileName());
						System.out.println("=====^^^^^^^^^^^^^^^^attFileNameNew^^^^^^^^^^^^^^^"+attFileNameNew);
				}
			}catch(java.lang.IllegalArgumentException e)
			{attFileNameNew=casedocEntity.getAttFileName() ;
			System.out.println("=====^^^^^^^^^error error error^^^^^^^^^"+attFileNameNew);     }
                                    //System.out.println("#######333333333333333######cdataCaseDetail=");
                                    //System.out.println("#######333333333333333######cdataCaseDetail.getOpenedTime()="+cdataCaseDetail.getOpenedTime());

                String temp="&nbsp";
                String openTime=cdataCaseDetail.getOpenedTime()==null?temp: showData.CheckNull(sdFormat.format(cdataCaseDetail.getOpenedTime() ) );
                 String submitTime=cdataCaseDetail.getSubmitTime()==null?temp: showData.CheckNull(sdFormat.format(cdataCaseDetail.getSubmitTime() ) ) ;

                                    //System.out.println("#######4444444######cdataCaseDetail=");

                      //cdataCaseDetail.getUserId()==null? temp:showData.CheckNull(cdataCaseDetail.getUserAccount().getUserName())
                   //   cdataCaseDetail.getCountryId()==null? temp:showData.CheckNull(cdataCaseDetail.getCountry().getCountryName())
                 //     cdataCaseDetail.getCaseDetStatus()==null? temp:showData.CheckNull(cdataCaseDetail.getCaseDetStatus())
      %>
  <!-- History Bar -->
  <tr name="HistoryBar" id="HistoryBar" class="<%= historyBarClassname %>" onMouseOver="rowOver(this)" onMouseOut="rowOut(this)" onClick="<%= historyBarOnClickScript %>">
    <td align="left" nowrap><%= openTime%> - <%= submitTime%> </td>
    <%System.out.println("#######HistoryBar  55555555######");
// System.out.println("#######HistoryBar  55555555##getUserId####"+cdataCaseDetail.getUserId());
//  System.out.println("#######HistoryBar  55555555###temp###"+temp);
 // System.out.println("#######HistoryBar  55555555###getUserAccount###"+cdataCaseDetail.getUserAccount());
  //System.out.println("#######HistoryBar  55555555###getUserName###"+cdataCaseDetail.getUserAccount().getUserName());
  //System.out.println("#######HistoryBar  55555555###getUserSurname###"+cdataCaseDetail.getUserAccount().getUserSurname());
    %>
    <td align="center" nowrap><%=cdataCaseDetail.getUserAccount()==null? temp:showData.CheckNull(cdataCaseDetail.getUserAccount().getUserName())%>
                                              <%= cdataCaseDetail.getUserAccount() ==null? temp:showData.CheckNull(cdataCaseDetail.getUserAccount().getUserSurname()) %>
    </td>
   <%System.out.println("#######HistoryBar  66666666666######");%>
    <td align="center" nowrap><%= cdataCaseDetail.getCountryId()==null? temp:showData.CheckNull(cdataCaseDetail.getCountry().getCountryName())%></td>
  <%System.out.println("#######HistoryBar  77777777######");%>
    <td align="center" nowrap><%= cdataCaseDetail.getCaseDetStatus()==null? temp:CfhdCaseHead.getStatusDesc(cdataCaseDetail.getCaseDetStatus())%></td>
   <%System.out.println("#######HistoryBar   88888888888######");

   %>
    <!--noom  21 12 2004 �� ��� Undefined �͡-->
    <!--td align="center" nowrap><%//  if(i<(vectorSize-1)){ %> Some Action<%//}else{%>Undefined<%//}%></td>
       <td align="center" nowrap>
        <% // if(i<(vectorSize-1)){%>
          <img src="../images/icon/toolbar/nSaveAs.gif" width="21" height="21" align="bottom" onClick="downloadThis('keyInformation')">
          <%//}else{ %>
          <img src="../images/icon/toolbar/nEdit.gif" width="21" height="21" align="bottom">
          <% // }

       //    cdataCaseDetail.getCaseAction()==null? temp:showData.CheckNull(CfhdCaseDetail.getDetailDesc(cdataCaseDetail.getCaseAction()))
          %>

      </td-->
     <td align="center" nowrap> <%=cdataCaseDetail.getCaseAction()==null? temp:showData.CheckNull(CfhdCaseDetail.getDetailDesc(cdataCaseDetail.getCaseAction()))%></td>
       <%System.out.println("####### HistoryBar   99999999999999######");%>

       <td align="center" nowrap>

       <%
       //System.out.println("#######99999999999999>>>>######"+casedocEntity);
       if(casedocEntity!=null){
            if(!(showData.CheckNull(casedocEntity.getAttFileName()).equals(""))){

       %>
          <img alt="Download" src="../images/icon/toolbar/nSaveAs.gif" width="21" height="21" align="bottom" onClick="download(<%=i%>)" >
           <%}else out.print("<DIV style='height: 20px'>&nbsp;</DIV>");
             }else out.print("<DIV style='height: 20px'>&nbsp;</DIV>");
           %>
      </td>

    <!-- END   noom  21 12 2004 �� ��� Undefined �͡-->
   </tr>
  <%
 // if(i<(vectorSize)-1){ //If it is 'undefined status it'll not show %>
  <tr id="HistoryDesc" class="<%= historyDescClassname %>" style="height:50px;">
    <!-- History Description  -->
    <td colspan="6"  id="historyDescTable">
    <!-- start case detail, maybe use iframe for deatail of the case.  -->
        <table width="99%"  border="0" cellspacing="2" cellpadding="2">
        <!--************�á table*************-->
				<TR>
					<TD colspan="3">
						<FIELDSET class="titleFont">
						<LEGEND class="titleFont">History Detail</LEGEND>

						<TABLE align="center" width="100%" border="0">
						    <%//System.out.println("#######10101010######");%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT>  Case Type : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getCaseTypeDesc(pdataCaseDetail.getCaseDetType()))%>"  readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT>  Severity : </TD>
		<TD width="173"><INPUT type="text" value="<%=showData.CheckNull(CfhdCaseHead.getServerityDesc(""+pdataCaseDetail.getCaseDetServerity()))%>"  readonly="readonly" class="disabledTxtField"></TD>
	</TR>
	    <%System.out.println("#######History Detail   11 11 11######");%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Requalify Type To : </TD>
		<TD width="<%=inputColWidth%>"><INPUT type="text"   value="<%=showData.CheckNull(CfhdCaseHead.getCaseTypeDesc(cdataCaseDetail.getCaseDetType()))%>" readonly="readonly" class="disabledTxtField"></TD>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Change Severity To : </TD>
		<TD width="173"><INPUT type="text"  value="<%=showData.CheckNull(CfhdCaseHead.getServerityDesc(""+cdataCaseDetail.getCaseDetServerity()))%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
		<%System.out.println("###### History Detail   22222222####");%>
<%
String temName="";
String temSurName="";
 if(cdataCaseDetail.getUserAccount()!=null){
         temName=cdataCaseDetail.getUserAccount().getUserName();
         temSurName=cdataCaseDetail.getUserAccount().getUserSurname();
         if(temName == null){
               temName = "&nbsp;";
         }else if(temSurName == null){
               temSurName = "&nbsp;";
         }
    }
 else{
         temName = "&nbsp;";
        temSurName = "&nbsp;";
 }
%>

	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Owner Name : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" value="<%=temName%> <%=temSurName%>"style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
		<%System.out.println("####### History Detail   333333#####");%>
<%
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Udong : change transfer to someone be name and surname
	String		nameTransfer		=	"";
	String		surnameTransfer	=	"";

	if(cdataCaseDetail.getTransferTo()!=null){
		    System.out.println("cdataCaseDetail.getTransferTo()!=null=="+cdataCaseDetail.getTransferTo());
		UserAccount				useraccountEntity		=	(UserAccount) levelManage.getUserAccount(cdataCaseDetail.getTransferTo());
		  System.out.println("11111111111useraccountEntity="+useraccountEntity);
		    if(useraccountEntity!=null){
                 System.out.println("11111111111useraccountEntity.getUserId()="+useraccountEntity.getUserId());
 		         nameTransfer		=	useraccountEntity.getUserName()==null? "":useraccountEntity.getUserName();
		         System.out.println("2222Noom"+nameTransfer);
		         System.out.println("useraccountEntity.getUserSurname()="+useraccountEntity.getUserSurname());
		         surnameTransfer	=	useraccountEntity.getUserSurname()==null?"":useraccountEntity.getUserSurname();
		           System.out.println("33333Noom"+surnameTransfer);
		        }
		System.out.println("........"+nameTransfer+"...."+surnameTransfer);
	}
	else{  System.out.println("cdataCaseDetail.getTransferTo()==null"); }

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Transfer To : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text"  value="<%=nameTransfer%> <%=surnameTransfer%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
		<%System.out.println("####### History Detail   4444444#####");%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> To User Level : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(UserLevel.getLevelName(cdataCaseDetail.getTransferToLv()))%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>
		<%System.out.println("####### History Detail   55555#####");%>
	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Type of Error : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><INPUT type="text" value="<%=showData.CheckNull(cdataCaseDetail.getCfhdErrType())%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"></TD>
	</TR>

		<%System.out.println("#######History Detail  6666#####");%>
<%
if(cdataCaseDetail!=null){
%>

	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>"><FONT color="red"></FONT> Detail : </TD>
		<TD colspan="3"><TEXTAREA rows="5" cols="10" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"><%=showData.CheckNull(cdataCaseDetail.getDetDesc())%></TEXTAREA></TD>
	</TR>

	<%System.out.println("####### History Detail   7777#####");%>
<%
    }
 if(casedocEntity!=null){
%>

	<TR >
		<TD class="titleFont" width="<%=labelColWidth%>">Attachment : </TD>
		<TD colspan="3" >

    		<INPUT type="text"  value="<%=showData.CheckNull(attFileNameNew)%>" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField">
            <%if(!(showData.CheckNull(casedocEntity.getAttFileName()).equals(""))){       %>
	     <img src="../images/icon/toolbar/nSaveAs.gif" width="21" height="21" align="bottom" onClick="download(<%=i%>)" alt="Download" >
	        <%}%>
		</TD>


	</TR>
	<%System.out.println("####### History Detail   88888#####");%>


	<TR>
		<TD class="titleFont" width="<%=labelColWidth%>">Description : </TD>
		<TD colspan="3" width="<%=inputColWidth%>"><TEXTAREA cols="10" rows="5" style="width: <%=longBoxWidth%>" readonly="readonly" class="disabledTxtField"><%=showData.CheckNull(casedocEntity.getAttDesc())%></TEXTAREA></TD>
	</TR>
<%System.out.println("#######History Detail   9999999999######");%>
	<%}%>
						</TABLE>

						</FIELDSET>
					</TD>
				</TR>
	       <!--************���á table*************-->

            </table>
            <%//  }  %>
            <!-- end case detail -->
    </td>
  </tr>
  <%
    // End of History
         }
  %>
<!-- end Scroll Table -->
<%} //end if(vectorSize>1)%>

		</FORM>
	</CENTER>
</DIV>
<%=fileInfoUtil.MasterFootTable()%>
<script type="text/javascript">
function download(detSeq)
{ //alert(detSeq);
document.all.frm.caseId.value='<%=caseID%>';
document.all.frm.detSeq.value=detSeq;
document.all.frm.docSeq.value="0";
document.all.frm.action.value="DowLoad";
//alert(frm.action);
frm.submit();

}
function UnlockCase()
{
	var okSaveButton = "<%=com.epro.standard.frontend.util.StringUtil.encode2Thai(com.epro.standard.frontend.datasetup.MessageManager.getString("okFormSubmitMessage"))%>";
	var cancelSaveButton = "<%=com.epro.standard.frontend.util.StringUtil.encode2Thai(com.epro.standard.frontend.datasetup.MessageManager.getString("cancelFormSubmitMessage"))%>";
if(showOConfirmDialog("Warning", "Have you made sure that no one else is currently updating this case?", "Yes", "No") == 1)
{
if(showOConfirmDialog("Warning", "To unlock and update <br>the case while another user is updating it can seriously damage the case integrity. Do you still want to continue?", "OK", "Cancel") == 1)
{

//location.href="/CFHD/servlet/com.softplus.carrefour.hd.frontend.servlet.process.CFHDPC06?action=UnlockCase"
  document.all.frm.caseId.value='<%=caseID%>';
document.all.frm.action.value="UnlockCase";
frm.submit();

 }
}
}

function CloseCase()
{
	var okSaveButton = "<%=com.epro.standard.frontend.util.StringUtil.encode2Thai(com.epro.standard.frontend.datasetup.MessageManager.getString("okFormSubmitMessage"))%>";
	var cancelSaveButton = "<%=com.epro.standard.frontend.util.StringUtil.encode2Thai(com.epro.standard.frontend.datasetup.MessageManager.getString("cancelFormSubmitMessage"))%>";

if(showOConfirmDialog("Close Case", "Do you want to Close Case ?", okSaveButton, cancelSaveButton) == 1)
{
  document.all.frm.caseId.value='<%=caseID%>';
document.all.frm.action.value="CloseCase";
frm.submit();
}

}
</script>
<%
     } //END check for no case id.
%>
</BODY>
</HTML>
 <%System.out.println("####### @@@@@@@@@END@@@@@@@######");%>
